export const useAuth = () => {
    const user = useState('auth-user', () => null)

    const fetchMe = async () => {
        const { data } = await useFetch('/api/secure/user/me', { method: 'GET' })
        user.value = data.value
        console.log('user1', data.value)
    }

    const logout = async () => {
        await useFetch('/api/auth/logout', { method: 'POST' })
        user.value = null
        navigateTo('/login')
    }

    return { user, fetchMe, logout }
}